package publics;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

import Pages.DoctorListPage;
import Pages.HospitalsList;
import Pages.IndexPage;
import Pages.LoginPage;
import Pages.LoginoutPage;

public class Service implements ISevice {

	private WebDriver driver;
	private String baseUrl;
	public Service()
	{
		baseUrl = "http://192.168.0.186:2001/";
		driver = new FirefoxDriver();
		driver.manage().window().maximize();
		driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
	}
	public Service(WebDriver _driver,String _baseUrl)
	{
		baseUrl = _baseUrl;
		driver = _driver;
		driver.manage().window().maximize();
		driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
	}
	@Override
	public void Action_doctorlist(int index) {
		// TODO Auto-generated method stub
		DoctorListPage.Page_doctor(driver,index).click();
	}

	@Override
	public void Cli_Book(int index) {
		// TODO Auto-generated method stub
		WebElement element = HospitalsList.Clinic_book(driver,index);
		element.click();
	}

	@Override
	public void Cli_Book() {
		// TODO Auto-generated method stub
		WebElement element = HospitalsList.Clinic_book(driver);
		element.click();
	}

	@Override
	public void Cli_checkbox() {
		// TODO Auto-generated method stub
		HospitalsList.Clinic_checkbox(driver).click();
	}

	@Override
	public void Cli_scroll() {
		// TODO Auto-generated method stub
		WebElement element = HospitalsList.Clinic_book(driver);
		Actions actions=new Actions(driver);
		actions.moveToElement(element).perform();
	}

	@Override
	public void clinicservice() {
		// TODO Auto-generated method stub
		Actions action=new Actions(driver);
		WebElement element=IndexPage.clinicservice(driver);
		action.click(element).perform();
	}

	@Override
	public void clinicregist() {
		// TODO Auto-generated method stub
		IndexPage.clinicregiste(driver).click();
	}

	@Override
	public void login(String username, String password, String vercode) {
		// TODO Auto-generated method stub
		LoginPage.login_username(driver).clear();
		LoginPage.login_username(driver).sendKeys(username);
		LoginPage.login_password(driver).clear();
		LoginPage.login_password(driver).sendKeys(password);
		LoginPage.login_vercode(driver).clear();
		LoginPage.login_vercode(driver).sendKeys(vercode);
		LoginPage.login_button(driver).click();
	}

	@Override
	public void loginout() {
		// TODO Auto-generated method stub
		LoginoutPage.loginout_button(driver).click();
	}
	

}
